package com.hongxun.project.assets.bDivice.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hongxun.framework.aspectj.lang.annotation.Log;
import com.hongxun.framework.aspectj.lang.enums.BusinessType;
import com.hongxun.project.assets.bDivice.domain.BDivice;
import com.hongxun.project.assets.bDivice.service.IBDiviceService;
import com.hongxun.framework.web.controller.BaseController;
import com.hongxun.framework.web.page.TableDataInfo;
import com.hongxun.framework.web.domain.AjaxResult;
import com.hongxun.common.utils.poi.ExcelUtil;

/**
 * 配电设备基础 信息操作处理
 * 
 * @author hongxun
 * @date 2019-03-19
 */
@Controller
@RequestMapping("/assets/bDivice")
public class BDiviceController extends BaseController
{
    private String prefix = "assets/bDivice";
	
	@Autowired
	private IBDiviceService bDiviceService;
	
//	@RequiresPermissions("assets:bDivice:view")
	@GetMapping()
	public String bDivice()
	{
	    return prefix + "/bDivice";
	}
	
	/**
	 * 查询配电设备基础列表
	 */
//	@RequiresPermissions("assets:bDivice:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(BDivice bDivice)
	{
		startPage();
        List<BDivice> list = bDiviceService.selectBDiviceList(bDivice);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出配电设备基础列表
	 */
	@RequiresPermissions("assets:bDivice:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BDivice bDivice)
    {
    	List<BDivice> list = bDiviceService.selectBDiviceList(bDivice);
        ExcelUtil<BDivice> util = new ExcelUtil<BDivice>(BDivice.class);
        return util.exportExcel(list, "bDivice");
    }
	
	/**
	 * 新增配电设备基础
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存配电设备基础
	 */
	@RequiresPermissions("assets:bDivice:add")
	@Log(title = "配电设备基础", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(BDivice bDivice)
	{		
		return toAjax(bDiviceService.insertBDivice(bDivice));
	}

	/**
	 * 修改配电设备基础
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		BDivice bDivice = bDiviceService.selectBDiviceById(id);
		mmap.put("bDivice", bDivice);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存配电设备基础
	 */
	@RequiresPermissions("assets:bDivice:edit")
	@Log(title = "配电设备基础", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(BDivice bDivice)
	{		
		return toAjax(bDiviceService.updateBDivice(bDivice));
	}
	
	/**
	 * 删除配电设备基础
	 */
	@RequiresPermissions("assets:bDivice:remove")
	@Log(title = "配电设备基础", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(bDiviceService.deleteBDiviceByIds(ids));
	}
	
}
